package com.chenjie.executor.day16;


/**
 * packageName com.chenjie.executor.day14
 *
 * @author chenjie
 * @version JDK 8
 * @className TicketTask (此处以class为例)
 * @date 2024/5/28
 * @description TODO
 */
public class Task implements Runnable {
    private boolean flag = true;



    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    @Override
    public void run() {
        if (flag) {
            synchronized (Task.class) {
                try {
                    Thread.sleep(3000L);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(Thread.currentThread().getName()+"：睡醒了");
            }
        } else {
            synchronized (Main.class) {
                System.out.println(Thread.currentThread().getName()+"：人人都是程序员");

            }
        }

    }
}
